package com.syn.vr.db;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;

import com.gaoyi.basemodule.baseUtil.AppUtil;
import com.syn.vr.db.dao.RecordDao;
import com.syn.vr.db.entity.Record;

@Database(entities = {Record.class}, version = 1, exportSchema = false)
@TypeConverters({DateConverter.class})
public abstract class VrDatabase extends RoomDatabase {
    private static final String DB_NAME = "vr.db";
    public static final String TABLE_RECORD = "tim_record";

    private volatile static VrDatabase INSTANCE;

    public abstract RecordDao getRecordDao();

    public static synchronized VrDatabase getDatabase() {
        if (INSTANCE == null) {
            synchronized (VrDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(AppUtil.getContext(),
                                    VrDatabase.class, DB_NAME)
                            .build();
                }
            }
        }
        return INSTANCE;
    }
}
